package polymorphic.apply;

/**
 * Created with IntelliJ IDEA.
 * ClassName: AniamlTest
 * Package: polymorphic.apply
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-11-22
 * Time: 18:38
 */

public class AnimalTest {

    public static void main(String[] args) {
        AnimalTest test = new AnimalTest();

        test.adopt(new Dog());
    }

    public void adopt(Animal animal) {
        animal.eat();
        animal.jump();
    }

}

class Animal {
    public void eat() {
        System.out.println("动物进食");
    }

    public void jump() {
        System.out.println("动物跳");
    }
}

class Dog extends Animal {
    @Override
    public void eat() {
        System.out.println("狗吃骨头");
    }

    @Override
    public void jump() {
        System.out.println("狗急跳墙");
    }

    public void watchDoor() {
        System.out.println("狗 看家~~~");
    }
}

class Cat extends Animal {
    @Override
    public void eat() {
        System.out.println("猫吃鱼");
    }

    @Override
    public void jump() {
        System.out.println("猫跳~~");
    }

    public void catchMouse() {
        System.out.println("猫捉老鼠");
    }
}
